import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import type { SettingsStore } from '../types';

export const useSettingsStore = create<SettingsStore>()(
  persist(
    (set) => ({
      sidecarUrl: 'http://localhost:3000',
      agentConfig: {
        model: 'claude-3-5-sonnet-20241022',
        maxTurns: 10,
      },

      setSidecarUrl: (url) => set({ sidecarUrl: url }),

      setAgentConfig: (config) =>
        set((state) => ({
          agentConfig: { ...state.agentConfig, ...config },
        })),
    }),
    {
      name: 'cagent-settings',
    }
  )
);

